class BinarySearch(object):
    def __init__(self, *, init_value, max_value, min_value, resolution):
        if type(init_value) != type(max_value) or type(init_value) != type(min_value) or type(init_value) != type(resolution):
            raise TypeError

        self.__init_config_value = init_value
        self.__max_config_value = max_value
        self.__min_config_value = min_value
        self.__config_resolution = resolution
        self.reset()
    
    def __str__(self):
        return 'This is a Binary Search for RFC 2544 and RFC2889'

    def reset(self):
        self.__current_value = self.__init_config_value
        self.__current_max = self.__max_config_value
        self.__current_min = self.__min_config_value
        self.__max_config_tested = False
        self.__min_config_tested = False

    def update_test_resultresult(self, result):
        if self.__current_value == self.__min_config_value:
            self.__min_config_valueTested = True
        elif self.__current_value == self.__max_config_value:
            self.__max_config_valueTested = True

        if result:
            self.__min_config_valueTested = True
            self.__current_min = self.__current_value
            if (self.__current_max-self.__current_min) > self.__config_resolution:
                self.__current_value = (self.__current_max+self.__current_min)/2
                return (False, self.__current_value)
            else:
                if self.__max_config_valueTested:
                    return (True, self.__current_value)
                else:  # must test the MaxVal
                    self.__max_config_valueTested = True
                    self.__current_value = self.__current_max = self.__max_config_value
                    return (False, self.__current_value)
        else:
            self.__max_config_valueTested = True
            self.__current_max = self.__current_value
            if self.__current_max-self.__current_min > self.__config_resolution:
                self.__current_value = (self.__current_max+self.__current_min)/2
                return (False, self.__current_value)
            else:
                if self.__min_config_valueTested:
                    return (True, self.__current_value)
                else:  # must test the MinVal
                    self.__min_config_valueTested = True
                    self.__current_value = self.__current_min = self.__min_config_value
                    return (False, self.__current_value)


if __name__ == '__main__':
    print(BinarySearch)